﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using DAL;
using Entities;
using BUS;
using Utility;

public partial class A_LetsDeal_DoanhNghiep_doanhnghiepdangky : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }


    protected void bt_dangky_Click(object sender, EventArgs e)
    {
        if (txt_tentaikhoan.Text != "" && txt_matkhau1.Text != "" &&
            txt_madoanhnghiep.Text != "" && txt_tendoanhnghiep.Text != "" && txt_diachi.Text != "" &&
            txt_dienthoai.Text != "" && txt_website.Text != "")
        {
            int kh = Tbl_DoanhNghiep_BUS.TestUsername(txt_tentaikhoan.Text);
            if (kh == 1)
            {
                lit_error.Text = "<font color='red'>Tên tài khoản đã tồn tại</font>";
            }
            else
            {
                Tbl_DoanhNghiep_Entities doanhnghiep = new Tbl_DoanhNghiep_Entities();
                doanhnghiep.MaDN = txt_madoanhnghiep.Text;
                doanhnghiep.TenDN = txt_tendoanhnghiep.Text;
                doanhnghiep.DiaChi = txt_diachi.Text;
                doanhnghiep.SDT = txt_dienthoai.Text;
                doanhnghiep.WebSite = txt_website.Text;
                doanhnghiep.GioiThieu = FreeTextBox1.Text;
                doanhnghiep.TaiKhoan = txt_tentaikhoan.Text;
                doanhnghiep.MatKhau = txt_matkhau1.Text;
                doanhnghiep.SoDuTaiKhoan = 0;
                doanhnghiep.LoaiTK = 2;
                int stt = Tbl_DoanhNghiep_BUS.Insert(doanhnghiep);
                Response.Redirect("~/A_LetsDeal-DoanhNghiep/dangkythanhcong.aspx");
            }
        }
    }

    protected void bt_kiemtra_Click(object sender, EventArgs e)
    {
        int khachhang = Tbl_DoanhNghiep_BUS.TestUsername(txt_tentaikhoan.Text);
        if (khachhang == 1)
        {
            lit_error.Text = "<font color='red' size='-1'>Tên tài khoản đã tồn tại</font>";
        }
        else
        {
            lit_error.Text = "<font color='red' size='-1'>Có thể sử dụng tên này</font>";
        }

    }
}


